package com.fsgom.gool.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fsgom.common.util.Generics;
import com.fsgom.gool.bean.GoolArtcl;
import com.fsgom.gool.bean.GoolArtclInfo;
import com.fsgom.gool.bean.GoolArtclRcmd;
import com.fsgom.gool.repository.GoolArtclRepository;

@Service
public class GoolArtclServiceImpl implements GoolArtclService {

	@Autowired
	private GoolArtclRepository artclRepository;
	
	@Override
	public GoolArtclInfo getArtclInfo(int userSeq) {
		return artclRepository.selectArtclInfo(userSeq);
	}

	@Override
	public List<GoolArtcl> getArtclLst(int userSeq, int pageNo, int rowCnt) {
		Map<String, Object> params = Generics.map();
		params.put("userSeq", userSeq);
		params.put("pageNo", pageNo);
		params.put("rowCnt", rowCnt);
		return artclRepository.selectArtclLst(params);
	}

	@Override
	public List<GoolArtclRcmd> getArtclRcmd(int upprArtclSeq, String delYn) {
		Map<String, Object> params = Generics.map();
		params.put("upprArtclSeq", upprArtclSeq);
		params.put("delYn", delYn);
		return artclRepository.selectArtclRcmd(params);
	}

	@Override
	public void addArtcl(int artclCatId, String artclCont,
			String artclMediaUrl, String artclType, int artclWrtrUserSeq) {
		Map<String, Object> params = Generics.map();
		params.put("artclCatId", artclCatId);
		params.put("artclCont", artclCont);
		params.put("artclMediaUrl", artclMediaUrl);
		params.put("artclType", artclType);
		params.put("artclWrtrUserSeq", artclWrtrUserSeq);
		artclRepository.insertArtcl(params);
	}

	@Override
	public void modArtcl(int artclSeq, String delYn, boolean rcmdCnt) {
		Map<String, Object> params = Generics.map();
		params.put("artclSeq", artclSeq);
		params.put("delYn", delYn);
		params.put("rcmdCnt", rcmdCnt);
		artclRepository.updateArtcl(params);
	}

	@Override
	public void addArtclRcmd(int upprArtclSeq, String rcmdCont, int wrtrUserSeq) {
		Map<String, Object> params = Generics.map();
		params.put("upprArtclSeq", upprArtclSeq);
		params.put("rcmdCont", rcmdCont);
		params.put("wrtrUserSeq", wrtrUserSeq);
		artclRepository.insertArtclRcmd(params);
	}

	@Override
	public void modArtclRcmd(int artclRcmdSeq, String delYn) {
		Map<String, Object> params = Generics.map();
		params.put("artclRcmdSeq", artclRcmdSeq);
		params.put("delYn", delYn);
		artclRepository.updateArtclRcmd(params);
	}

}
